package start.demo01.fileIO;

import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Calculate {

    @Test
    public void t0() throws IOException {
        //332cfc3593b091ac0e157a800fb1c1599f9f72e69441e46b50ed84f5ab053b7681ebf4ed660a6a8bfccbf8e3ae9266e3c6016f08439fc36e157ef7aa8be7b14a
        //
        File file = new File("C:\\包管理\\主机安装包文件\\CentOS-7-x86_64-DVD-1810.iso");
        System.out.println("文件大小:"+file.length()/1024.0/1024/1024+"GB");
        FileInputStream fileInputStream = new FileInputStream(file);
        long start=System.currentTimeMillis();
//        String hex = DigestUtils.md5Hex(fileInputStream);
        String hex = DigestUtils.sha512Hex(fileInputStream);
        System.out.println("计算耗时:"+(System.currentTimeMillis()-start)/1000+"s");
        System.out.println(hex);
    }
}
